package com.sdleyou.treepro.common.service.impl;

import com.sdleyou.treepro.common.model.dao.SloganDO;
import com.sdleyou.treepro.common.model.vo.SloganVO;
import com.sdleyou.treepro.common.service.UserSloganManager;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;

@Service
public class UserSloganManagerImpl implements UserSloganManager {
    @Autowired
    private MongoTemplate mongoTemplate;

    @Override
    public SloganVO currentSlogan() {
        Query query = new Query(Criteria.where("status").is("SHOW"));
        SloganDO sloganDO = mongoTemplate.findOne(query, SloganDO.class);
        SloganVO sloganVO = new SloganVO();
        BeanUtils.copyProperties(sloganDO, sloganVO);
        return sloganVO;
    }
}
